package org.example.tliaswebmanagerment.mapper;


import org.apache.ibatis.annotations.*;
import org.example.tliaswebmanagerment.pojo.Dept;

import java.util.List;

@Mapper
public interface DeptMapper {
//
//    @Results({
//            @Result(column="create_time", property="createTime"),
//            @Result(column="update_time", property="updateTime")
//    })


    @Select("select id, name, create_time , update_time  from dept order by update_time desc")
    public List<Dept> findAll();

    @Delete("delete from dept where id=#{id}")
    public void deleteById(@Param("id") Integer id);  //注解Param，可以把参数id映射为#{id}
    //可以不用@Param，直接把参数id映射为#{id}

    @Insert("insert into dept(name, create_time, update_time) values(#{name}, #{createTime}, #{updateTime})")
    //SQL语句可以从传入的对象中获取对应的属性
    public void add(Dept dept);


    @Update("update dept set name=#{name}, update_time=#{updateTime} where id=#{id}")
    public void update(Dept dept);


    @Select("select id, name, create_time , update_time  from dept where id=#{id}")
    Dept findById(Integer id);
}
